package com.leostadyn.stackfarm.timestatistics.base;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.leostadyn.stackfarm.timestatistics.R;
import com.leostadyn.stackfarm.timestatistics.utils.SaveObjectTools;
import com.orhanobut.hawk.Hawk;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;

public class BaseApplication extends Application {

    private static Application application;
    static {

        SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) ->
                new ClassicsHeader(context)
                        .setAccentColor(context.getResources().getColor(R.color.colorPrimary))
                        .setTextSizeTitle(14)
        );// setDefaultRefreshFooterCreater
        SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) ->
                new ClassicsFooter(context)
                        .setAccentColor(context.getResources().getColor(R.color.colorPrimary))
                        .setTextSizeTitle(14));
    }

    //sn
    public static Application getApplication() {
        return application;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
//        super.attachBaseContext(LocaleHelper.onAttach(base, yuYan(base)));
        // you must install multiDex whatever tinker is installed!
        MultiDex.install(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        SaveObjectTools.INSTANCE(); // 初始化
        //Hawk 数据存储
        Hawk.init(this).build();
//        HeConfig.init("HE1906121522381987", "47355b62eb9341fe8c825154f1037ab3");
//        HeConfig.switchToFreeServerNode();


//        HeConfig.init("HE1904092257441772", "6c5a3319757a4302981858c2bb84f3c2");
//        HeConfig.switchToFreeServerNode();
    }
}
